This patch adds two macros for construction of the
authorkaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk>
Mon, 1 Aug 2005 09:26:51 +0000 (09:26 +0000)
committerkaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk>
Mon, 1 Aug 2005 09:26:51 +0000 (09:26 +0000)
frame_and_sectors field in blkif messages, to eliminate the
"magic shifts" in the blkif code.

It also increases the number of bits representing the sector
number within a page, from 3 to 5, to allow page sizes up to
16K (needed for IA64).

Tested to still work on x86.

Signed-off-by: Matthew Chapman <matthewc@hp.com>
linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c
linux-2.6-xen-sparse/drivers/xen/blkfront/vbd.c
xen/include/public/io/blkif.h

index 1f524e3008357b29c57d783319dd9961c24d8782..04c0f0fdbfe4c05020a2dc5dd86f5c717d3ef6f8 100644 (file)
@@ -329,11 +329,11 @@ static int blkif_queue_request(struct request *req)
                 buffer_ma >> PAGE_SHIFT;
 
             ring_req->frame_and_sects[ring_req->nr_segments++] =
-                (((u32) ref) << 16) | (fsect << 3) | lsect;
+                blkif_fas_from_gref(ref, fsect, lsect);
 
 #else
             ring_req->frame_and_sects[ring_req->nr_segments++] =
-                buffer_ma | (fsect << 3) | lsect;
+                blkif_fas(buffer_ma, fsect, lsect);
 #endif
         }
     }
@@ -832,10 +832,10 @@ static int blkif_queue_request(unsigned long   id,
                 buffer_ma >> PAGE_SHIFT;
 
             req->frame_and_sects[req->nr_segments] =
-                (((u32) ref ) << 16) | (fsect << 3) | lsect;
+                blkif_fas_from_gref(ref, fsect, lsect);
 #else
             req->frame_and_sects[req->nr_segments] =
-                buffer_ma | (fsect << 3) | lsect;
+                blkif_fas(buffer_ma, fsect, lsect);
 #endif
             if ( ++req->nr_segments < BLKIF_MAX_SEGMENTS_PER_REQUEST )
                 sg_next_sect += nr_sectors;
@@ -887,9 +887,9 @@ static int blkif_queue_request(unsigned long   id,
 
     blk_shadow[xid].frame[0] = buffer_ma >> PAGE_SHIFT;
 
-    req->frame_and_sects[0] = (((u32) ref)<<16)  | (fsect<<3) | lsect;
+    req->frame_and_sects[0] = blkif_fas_from_gref(ref, fsect, lsect);
 #else
-    req->frame_and_sects[0] = buffer_ma | (fsect<<3) | lsect;
+    req->frame_and_sects[0] = blkif_fas(buffer_ma, fsect, lsect);
 #endif
 
     /* Keep a private copy so we can reissue requests when recovering. */    
@@ -1057,7 +1057,7 @@ void blkif_control_probe_send(blkif_request_t *req, blkif_response_t *rsp,
 
     gnttab_grant_foreign_access_ref( ref, rdomid, address >> PAGE_SHIFT, 0 );
 
-    req->frame_and_sects[0] = (((u32) ref) << 16) | 7;
+    req->frame_and_sects[0] = blkif_fas_from_gref(ref, 0, (PAGE_SIZE/512)-1);
 
     blkif_control_send(req, rsp);
 }
index 233aeda16c27597279a98c9891827661367b11fd..210bfa910575a50af048a578efebb1c269a88d10 100644 (file)
@@ -137,7 +137,7 @@ static vdisk_t *xlvbd_probe(int *ret)
     blkif_control_probe_send(&req, &rsp,
                              (unsigned long)(virt_to_machine(buf)));
 #else
-    req.frame_and_sects[0] = virt_to_machine(buf) | 7;
+    req.frame_and_sects[0] = blkif_fas(virt_to_machine(buf), 0, ((PAGE_SIZE/512)-1);
 
     blkif_control_send(&req, &rsp);
 #endif
index a5b0147b399e9e0336dc55cd2b6837f4e4bd8689..45d4132e8b24ab137ea22775e5193001de321076 100644 (file)
@@ -36,7 +36,7 @@ typedef struct blkif_request {
     blkif_vdev_t   device;       /* only for read/write requests         */
     unsigned long  id;           /* private guest value, echoed in resp  */
     blkif_sector_t sector_number;/* start sector idx on disk (r/w only)  */
-    /* @f_a_s[2:0]=last_sect ; @f_a_s[5:3]=first_sect                        */
+    /* @f_a_s[4:0]=last_sect ; @f_a_s[9:5]=first_sect                        */
 #ifdef CONFIG_XEN_BLKDEV_GRANT
     /* @f_a_s[:16]= grant reference (16 bits)                                */
 #else
@@ -47,10 +47,12 @@ typedef struct blkif_request {
     unsigned long  frame_and_sects[BLKIF_MAX_SEGMENTS_PER_REQUEST];
 } blkif_request_t;
 
-#define blkif_first_sect(_fas) (((_fas)>>3)&7)
-#define blkif_last_sect(_fas)  ((_fas)&7)
+#define blkif_fas(_addr, _fs, _ls) ((addr)|((_fs)<<5)|(_ls))
+#define blkif_first_sect(_fas) (((_fas)>>5)&31)
+#define blkif_last_sect(_fas)  ((_fas)&31)
 
 #ifdef CONFIG_XEN_BLKDEV_GRANT
+#define blkif_fas_from_gref(_gref, _fs, _ls) (((_gref)<<16)|((_fs)<<5)|(_ls))
 #define blkif_gref_from_fas(_fas) ((_fas)>>16)
 #endif